package stardecision.core;

import setupapplication.core.SetupRunner;
import stardecision.data.UserDecision;
import stardecision.logic.ValidateDecision;
import stardecision.ui.UserWelcomeMessage;

public class ApplicationRunner implements Runnable_Interface, Validatable_Interface  {
	
	public String decision;

	@Override
	public void run() {
		
		do {
			
			userWelcomeMessage();
			decision = getDecisionFromUser();
			if(validateDecision(decision) == true){
				setUpApplication();
			}
			
		}while(decision.equals("no") == false);
	}

	

	private void setUpApplication() {
		
		SetupRunner setupRunner = new SetupRunner();
		setupRunner.run();
		
	}



	private String getDecisionFromUser() {
		
			UserDecision userDecision = new UserDecision();
			decision = userDecision.getDecisionFromUser();
			return decision;
		
	}
	
	/**
	 * get user welome message
	 */
	private void userWelcomeMessage() {
		
		UserWelcomeMessage userWelcomeMessage = new UserWelcomeMessage();
		userWelcomeMessage.message();
		
	}



	@Override
	public boolean validateDecision(String decision) {
		
		ValidateDecision validateDecision = new ValidateDecision();
		boolean validate = validateDecision.validate(decision);
		return validate;
		
	}

}
